#ifndef TCPPROTOCOLWORKER_H
#define TCPPROTOCOLWORKER_H

#include <QObject>
class QTcpSocket;
class QHostAddress;


#include <pcl/point_cloud.h>
#include <pcl/visualization/pcl_visualizer.h>   
#include <opencv2/imgproc.hpp> 

class TcpProtocolWorker : public QObject
{
    Q_OBJECT
public:
    explicit TcpProtocolWorker(QObject *parent = nullptr);
    ~TcpProtocolWorker();
signals:
    void connected();
    void disconnected();
    void readyReadData(const QByteArray& mess, const QHostAddress& adress);
    void errorOccurred(const QString& data);

    void depthImageReady(const QImage& image);
    void sendPointCloud(const std::shared_ptr<pcl::PointCloud<pcl::PointXYZ>>& cloud);

    void sendProtocolConnectStatus(bool flag);
public slots:
    void connectToServer(const QString& ip,quint16 port);
    void sendData(const QByteArray& data);

private slots:
    void onReadyRead();

private:
    QTcpSocket* m_socket;
    QString m_ip;
    quint16 m_port;
};

#define TcpProtocolWorkerRelease Singleton<TcpProtocolWorker>::Release()
#define TcpProtocolWorkerInstance Singleton<TcpProtocolWorker>::GetInstance()


#endif // TCPDEPTHWORKER_H
